package com.itmuch.cloud;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.netflix.zuul.filters.ProxyRequestHelper;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;

public class OkHttpRoutingFilter extends ZuulFilter{

	@Autowired
	private ProxyRequestHelper helper;
	
	@Override
	public Object run() {
		RequestContext ctx = RequestContext.getCurrentContext();
		HttpServletRequest request = ctx.getRequest();
		
		String host=request.getRemoteHost();
		System.out.println("route request host:"+host); 
		return null;
	}

	@Override
	public boolean shouldFilter() {
		//return RequestContext.getCurrentContext().getRouteHost() != null&& RequestContext.getCurrentContext().sendZuulResponse();
		return true;
	}

	@Override
	public int filterOrder() { 
		return 2;
	}

	@Override
	public String filterType() {
		return "ROUTE_TYPE";
	}

}
